//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>

#include "ArffAttributeSelection.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#define MESSAGE 0
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main (int argc, char** argv) {
  
  String* namefileBuffer = NULL;
  String* namefileOut    = NULL;
  String* typeData       = NULL;
  
  if (argc < 4) {
    
    if (MESSAGE) {
      cout << "Error in the input parameters! Must by like: " << endl;
      cout << "./StoreSelectedFeatureTogether <Filename with attributes selection buffer>";
      cout <<                               " <Filename with a list of attributes>";
      cout <<                               " <Type attributes>";
      cout << endl;
    }
    
    return 0;
    
  }
  else {
    
    namefileBuffer = new String(argv[1]);
    namefileOut    = new String(argv[2]);
    typeData       = new String(argv[3]);
    
    if (MESSAGE) {
      cout << "----------------------------------------------------------------------------------------------------------------" << endl;
      cout << " Filename with attributes selection buffer : " << argv[1] << endl;
      cout << "        Filename with a list of attributes : " << argv[2] << endl;    
      cout << "                           Type attributes : " << argv[3] << endl;    
      cout << "----------------------------------------------------------------------------------------------------------------" << endl;
    }
    
  }
  
  ArffAttributeSelection* arffAttributeSelection = new ArffAttributeSelection ();
  
  cout << "Preparing the files..." << endl;
  arffAttributeSelection->FilenameIn(namefileBuffer);
  arffAttributeSelection->FilenameOut(namefileOut);
  
  cout << "Loading the data..." << endl;
  if (!arffAttributeSelection->LoadSelectionResult(typeData))
    cout << "Error loading data!" << endl;
  
  cout << "Adding the result to output file..." << endl;
  if (!arffAttributeSelection->AddDataToFile())
    cout << "Error writing the new list of attributes!" << endl;
  
  cout << "Finished..." << endl << "Good Bye" << endl;
  
  if (arffAttributeSelection) delete arffAttributeSelection;
  
  if (namefileBuffer)         delete namefileBuffer;
  if (namefileOut)            delete namefileOut;

  return EXIT_SUCCESS;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

